import multiprocessing
import os


def copy_file(file_name, source_dir, dest_dir):
    source_file = source_dir + '/' + file_name
    dest_file = dest_dir + '/' + file_name
    if not os.path.exists(dest_file):
        with open(source_file, "rb") as f:
            with open(dest_file, "wb") as f1:
                while True:
                    data = f.read(1024)
                    if data:
                        f1.write(data)
                    else:
                        break
    else:
        print(f"{file_name} is not exists")


if __name__ == '__main__':
    source_dir = "D:/qq/graphic"
    dest_dir = "D:/qq/graphic_backup"
    try:
        os.mkdir(dest_dir)
    except FileExistsError:
        pass
    file_list = os.listdir(source_dir)
    for file_name in file_list:
        sub_process = multiprocessing.Process(target=copy_file, args=(file_name, source_dir, dest_dir))
        sub_process.start()
